#include "symbol_table/SymbolTable.h"


SymbolTable::SymbolTable(void)
{
}


SymbolTable::~SymbolTable(void)
{
    SymbolTableMap::iterator it;
    for(it = m_mapTable.begin(); it!=m_mapTable.end(); ++it)
    {
        delete it->second;
    }
}

SymbolBase * SymbolTable::findSymbol( const std::string &strSymbolName ) const
{
    SymbolTableMap::const_iterator it = m_mapTable.find(strSymbolName);
    if(it == m_mapTable.end())
        return NULL;
    return it->second;
}

void SymbolTable::addSymbol( SymbolBase * pSymbol )
{
    SymbolTableMap::const_iterator it = m_mapTable.find(pSymbol->getSymbolName());
    if(m_mapTable.end() == it)
    {
        m_mapTable.insert(std::make_pair(pSymbol->getSymbolName(), pSymbol));
    }
    return ;
}

